<template>
	<view style="margin: 30rpx;">
		商品
		<view v-for="item in pro" style="margin: 40rpx; align-items: center;"
		
		>
			<uni-row>
				<uni-col :span="6">
					<view>
						<image src="../../static/logo.png" style="width: 100rpx; height: 100rpx;"></image>
					</view>
				</uni-col>
				<uni-col :span="12">
					<view>
						{{item.vname}}---{{item.price}}---{{item.gprice}}
					</view>
				</uni-col>
				<uni-col :span="6">
					<view>
						<u-button style="font-size: 30rpx;" @click="listing(item)">{{item.type}}</u-button>
					</view>
				</uni-col>
			</uni-row>
			
			
			{{$store.state.id}}
		</view>
		<u-button @click="add">新增商品</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					store:this.$store.state.id
				},
				pro:[],
				commodit:{
					store:this.$store.state.id
				}
			};
		},
		upLoad(){
			this.show();
		},
		created() {
			
			const baseUrl="http://localhost:8888"
			uni.request({
				url:baseUrl+'/s/commodit/find',
				method:"POST",
				data:this.commodit
			}).then(res=>{
				console.log(this.$store.state.id);
				console.log(res.data.data)
				this.pro=res.data.data
				
			})
			this.show()
		},
		methods:{
			listing(e){
				console.log(e)
				const baseUrl="http://localhost:8888"
				uni.request({
					url:baseUrl+'/s/commodit/'+e.name+'/'+e.status,
					method:"GET"
				}).then(res=>{
					console.log(res.data)
					this.show()
				})
			},
			show(){
				const baseUrl="http://localhost:8888"
				uni.request({
					url:baseUrl+'/s/commodit/find',
					method:"POST",
					data:this.commodit
				}).then(res=>{
					console.log(this.$store.state.id);
					console.log(res.data.data)
					this.pro=res.data.data
				
				})
			},
			add(){
				
				const baseUrl="http://localhost:8888"
				uni.request({
					url:baseUrl+'/s/operate/find/'+this.$store.state.id,
					method:"GET"
				}).then(res=>{
					if(res.data.data==null){
						console.log("您还没有认证")
					}else{
						uni.navigateTo({
							url:'/pages/addlist/addlist'
						})
					}
					
					
				})
				
				
				
				
				
			}
		}
	}
</script>

<style lang="scss">

</style>
